package com.chinacoal.hr.levelimpl.service.impl;

import com.chinacoal.hr.levelapi.entity.AttendanceAppealDetail;
import com.chinacoal.hr.levelimpl.dao.AttendanceAppealDetailDao;
import com.chinacoal.hr.levelimpl.service.AttendanceAppealDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: YunTao.Li
 * @create: 2019-11-18 23:58
 * @description:
 **/
@Service
public class AttendanceAppealDetailServiceImpl implements AttendanceAppealDetailService {

    @Autowired
    private AttendanceAppealDetailDao attendanceAppealDetailDao;


    /**
     * 新增考勤申诉单明细service实现
     *
     * @param record :
     * @return : java.util.Map<java.lang.String,java.lang.String>
     * @author : YunTao.Li
     * @date : 2019/11/21 2019/11/21
     */
    public Map<String, String> addAttendanceAppealDetail(AttendanceAppealDetail record) throws Throwable {
        Map<String, String> result = new HashMap<String, String>();
        result.put("code", "-1");

        try {
            attendanceAppealDetailDao.insertAttendanceAppealDetail(record);
        } catch (Throwable e) {
            e.printStackTrace();
            throw e;
        }

        result.put("code", "1");
        return result;
    }

    @Override
    public Map<String, String> updateAttendanceAppealDetail(AttendanceAppealDetail record) throws Throwable {
        Map<String, String> result = new HashMap<String, String>();
        result.put("code", "-1");

        try {
            attendanceAppealDetailDao.updateAttendanceAPpealDetail(record);
        } catch (Throwable e) {
            e.printStackTrace();
            throw e;
        }

        result.put("code", "1");
        return result;
    }

    /**
     * 根据申诉id查询申诉明细列表
     *
     * @param explainId : 考勤申诉id
     * @return : List<AttendanceAppealDetail>
     * @author : YunTao.Li
     * @date : 2019/11/26 2019/11/26
     */
    public List<AttendanceAppealDetail> getAttendanceAppealDetailListByAppealId(String explainId) throws Throwable {
        try {
            return this.attendanceAppealDetailDao.getAttendanceAppealDetailListByAppealId(explainId);
        } catch (Throwable e) {
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 根据申诉id删除此申诉下的所有申诉明细
     *
     * @param explainId :
     * @return : java.util.Map<java.lang.String,java.lang.String>
     * @author : YunTao.Li
     * @date : 2019/11/26 2019/11/26
     */
    @Override
    public Map<String, String> deleteAttendanceAppealDetailByExplainId(String explainId) throws Throwable {
        Map<String, String> result = new HashMap<String, String>();
        result.put("code", "-1");

        try {
            attendanceAppealDetailDao.deleteAttendanceAppealDetailByExplainId(explainId);
        } catch (Throwable e) {
            e.printStackTrace();
            throw e;
        }

        result.put("code", "1");
        return result;
    }
}
